import 'package:flutter/material.dart';
import 'package:tin_flutter/app/global.dart';

/// * 作者: Tao
/// * 日期: 2025/9/23
/// * 时间: 15:42
/// * 描述: 加载框
class LoadingDialog {
  /// 显示加载框
  /// * [text] 显示的文字
  static show({String text = "加载中..."}) {
    showDialog(
      context: navigatorKey.currentContext!,
      barrierDismissible: false,
      builder: (BuildContext context) {
        return AlertDialog(
          backgroundColor: Colors.white,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(8),
          ),
          contentPadding: EdgeInsets.symmetric(vertical: 30),
          content: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Container(
                width: 20,
                height: 20,
                child: CircularProgressIndicator(color: Colors.blue, strokeWidth: 2),
              ),
              SizedBox(width: 10),
              Text(
                text,
                style: TextStyle(
                  color: Colors.blue,
                ),
              ),
            ],
          ),
        );
      },
    );
  }

  /// 隐藏加载框
  static dismiss() {
    Navigator.of(navigatorKey.currentContext!).pop();
  }
}
